<template>
	<view class="contain">
		<view class="info-box">
			<view class="list-cell">
				<view class="list-cell-item">
					<view class="item-title">姓名：</view>
					<view class="item-info">{{registration.inputPerson || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">联系方式：</view>
					<view class="item-info">{{registration.inputPhone || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">身份证号：</view>
					<view class="item-info">{{registration.inputIdCard || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">返乡时间：</view>
					<view class="item-info">{{registration.inputTime || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">来源类型：</view>
					<view class="item-info">{{registration.resourceType == "0"?"国内":"国外"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">来源地：</view>
					<view class="item-info">{{registration.inputSource || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">返回地：</view>
					<view class="item-info">{{registration.inputTarget || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">详细地址：</view>
					<view class="item-info">{{registration.inputAddressDetail || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">交通方式：</view>
					<view class="item-info">{{registration.inputTransport || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">班次：</view>
					<view class="item-info">{{registration.inputShift || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">行程路径：</view>
					<view class="item-info">{{registration.inputTravelPath || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title" style="width: 360upx;">是否去过疫区：</view>
					<view class="item-info" style="color:green" v-if="registration.isToEpidemicArea == '0'">否</view>
					<view class="item-info" style="color:red" v-else>是</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">体温：</view>
					<view class="item-info">{{registration.inputTemperature || "无"}}</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">健康状况：</view>
					<view class="item-info" style="color:red" v-if="registration.inputHealth == '不健康'">不健康</view>
					<view class="item-info" style="color:green" v-else>健康</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title" style="width: 360upx;">是否做过核酸检测：</view>
					<view class="item-info" style="color:green" v-if="registration.isNucleicTest == '0'">否</view>
					<view class="item-info" style="color:red" v-else>是</view>
				</view>
				<view class="list-cell-item" style="display:block">
					<view class="item-title">健康码：</view>
					<view class="item-info" style="text-align:left;">
						<image v-for="(item,index) in registration.healthCodeImage" :src="item" style="width:62px;height:62px;margin-left:10px;margin-top:10px"></image>
					</view>
				</view>
				<view class="list-cell-item" style="display:block">
					<view class="item-title">行程码：</view>
					<view class="item-info" style="text-align:left;">
						<image v-for="(item,index) in registration.travelCodeImage" :src="item" style="width:62px;height:62px;margin-left:10px;margin-top:10px"></image>
					</view>
				</view>
				<view class="list-cell-item" style="display:block">
					<view class="item-title" style="width: 360upx;">核酸检测报告：</view>
					<view class="item-info" style="text-align:left;">
						<image v-for="(item,index) in registration.nucleicTestImage" :src="item" style="width:62px;height:62px;margin-left:10px;margin-top:10px"></image>
					</view>
				</view>
				<view class="list-cell-item">
					<view class="item-title">备注：</view>
					<view class="item-info">{{registration.inputRemark || "无"}}</view>
				</view>
			</view>
		</view>

		<view style="width: 100%">
			<button type="default" class="button_left_class" @click="goToLast">上一步</button>
			<button type="primary" class="button_right_class" @click="addRegistration">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				registration: {},
				areaCode: this.$api.util.getAreaCode(),
				userId: ""
			}
		},
		onLoad(option) {
			if (option && option.item) {
				this.registration = JSON.parse(decodeURIComponent(option.item))
			}
			let userInfo = uni.getStorageSync("userInfo")
			if (userInfo) {
				this.userId = userInfo.userUuid
			}
		},
		methods: {
			addRegistration() {
				let params = {
					name: this.registration.inputPerson,
					phone: this.registration.inputPhone,
					idCard: this.registration.inputIdCard,
					time: this.registration.inputTime,
					type: this.registration.resourceType,
					address: this.registration.inputSource,
					placeOfReturn: this.registration.inputTarget,
					detailAddress: this.registration.inputAddressDetail,
					trafficType: this.registration.inputTransport,
					shift: this.registration.inputShift,
					route: this.registration.inputTravelPath,
					epidemicArea: this.registration.isToEpidemicArea,
					temperature: this.registration.inputTemperature,
					health: this.registration.inputHealth == "健康" ? "1" : "0",
					test: this.registration.isNucleicTest,
					healthCodeImage: JSON.stringify(this.registration.healthCodeImage),
					travelCodeImage: JSON.stringify(this.registration.travelCodeImage),
					nucleicTestImage: JSON.stringify(this.registration.nucleicTestImage),
					remark: this.registration.inputRemark,
					category: "1",
					areaCode: this.areaCode,
					userId: this.userId
				}
				this.$api.request.addRegister(params, (res) => {
					if (res.body.status.statusCode == "0") {
						this.$api.msg("添加成功")
						setTimeout(() => {
							uni.navigateBack({
								delta: 2
							})
						}, 1000)
					} else {
						this.$api.msg("添加失败")
					}
				})
			},
			goToLast() {
				uni.navigateBack()
			}
		},
		components: {

		}
	}
</script>

<style scoped lang="scss">
	page {
		background: $page-color-base;
	}

	.info-box {
		width: calc(100% - 40upx);
		margin: 20upx;
		background-color: white;
		border-radius: 20upx;
	}

	.list-cell {
		padding: 20upx;

		.list-cell-item {
			padding: 30upx 0;
			display: flex;
			flex-direction: row;
			font-size: 30upx;
			justify-content: space-between;

			.item-title {
				width: 180upx;
				font-weight: border;
				color: #787684;
				margin-left: 20upx;
			}

			.item-info {
				width: calc(100% - 200upx);
				margin-right: 20upx;
				text-align: right;
			}
		}
	}

	.button_left_class {
		display: inline-block;
		margin-top: 20upx;
		width: 37%;
		margin-left: 10%;
		height: 80upx;
		line-height: 80upx;
		background-color: #1DA3EE !important;
		border-radius: 10upx;
		color: white;
		margin-bottom: 40upx;
	}

	.button_right_class {
		display: inline-block;
		margin-top: 20upx;
		width: 37%;
		margin-left: 6%;
		height: 80upx;
		line-height: 80upx;
		border-radius: 10upx;
		background-color: #1DA3EE !important;
		color: white;
		margin-bottom: 40upx;
	}
</style>
